package cn.gwm.flink.streaming.beans.estimateSoh;

import lombok.Data;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Objects;

/** 单条记录信息
 * @author GW00283474
 */
@Data
public class EstimateSohRecordPhev implements Serializable {

    /**
     * SOC电量
     */
    public BigDecimal BMS_BattSOC;
    /**
     * 车型配置码
     */
    public String model_code;
    /**
     * VCU状态
     */
    public Integer HCU_PowertrainSts;

    /**
     * 经度
     */
    BigDecimal longitude;
    /**
     * 纬度
     */
    BigDecimal latitude;

    /**
     * 电池健康状态
     */
    public BigDecimal BMS_SOH_R;
    /**
     * 车辆代码
     */
    public String deviceId;
    /**
     * 车型名称
     */
    public String model;
    /**
     * 车辆类型
     */
    public String vehicletype;
    /**
     * 单体最小电压
     */
    public BigDecimal BMS_CellVoltMin;
    /**
     * 单体最小电压两次的差值(本次减上一次)
     */
    public BigDecimal dvMin = new BigDecimal("0");
    /**
     * 单体最大电压
     */
    public BigDecimal BMS_CellMaxVolt;
    /**
     * 单体最大电压两次的差值(本次减上一次)
     */
    public BigDecimal dvMax = new BigDecimal("0");

    /**
     * 充电容量
     */
    public BigDecimal Q_Charge;
    /**
     * 放电容量
     */
    public BigDecimal Q_Discharge;
    /**
     * 计算电池累积充电容量
     */
    public BigDecimal cumulativeChrgAhRm;
    /**
     * 计算电池累积放电容量
     */
    public BigDecimal cumulativeDchrgAhRm;
    /**
     * 计算充放电容量差
     */
    public BigDecimal totlAh;
    /**
     * 计算充放电容量差两次的差值(本次减上一次)
     */
    public BigDecimal dQ = new BigDecimal("0");
    /**
     * 计算比值1(等于dQ除以dV_max)
     */
    public BigDecimal ratio1 = new BigDecimal("0");
    /**
     * 计算比值2(等于dQ除以dV_min)
     */
    public BigDecimal ratio2 = new BigDecimal("0");
    /**
     * 动力电池电流
     */
    public BigDecimal BMS_PackCurr_RM;

    /**
     * 时间戳
     */
    public Long item_time;
    /**
     * 车牌号
     */
    public String license_plate;

    /**
     * 电池类型
     */
    public String cell_battery_type ;
    /**
     * 电池平均温度
     */
    public Integer BMS_ModuleTempaverage;
    /**
     * 电池额定容量
     */
    public BigDecimal pack_capacity;
    /**
     * 内部最大额定SOC
     */
    public BigDecimal BMS_CellSOCMax = new BigDecimal("0.0");
    /**
     * 动力电池内部SOC最大值两次的差值(本次减上一次)
     */
    public BigDecimal differenceSocMax = new BigDecimal("0");
    /**
     * 内部最小额定SOC
     */
    public BigDecimal BMS_CellSOCMin = new BigDecimal("0.0");
    /**
     * 动力电池内部SOC最大值两次的差值(本次减上一次)
     */
    public BigDecimal differenceSocMin = new BigDecimal("0");
    /**
     * 判断是否OCV非平台有效性
     */
    public Boolean platformValidFlag = false;
    /**
     * 最大soc是否OCV非平台有效性
     */
    public Boolean platformValidFlagMax = false;

    /**
     * 最小soc是否OCV非平台有效性
     */
    public Boolean platformValidFlagMin =false;
    /**
     * 判断是否满足触发条件
     */
    public Boolean triggerFlag = false;
    /**
     * 判断是否满足使能条件
     */
    public Boolean enableFlag= false;
    /**
     * 判断是否休眠静止
     */
    public Boolean sleepStillFlag = false;
    /**
     * 判断是否在线静止
     */
    public Boolean onlineStillFlag = false;
    /**
     *
     * 是否满足容量法舍弃条件
     */
    public Boolean capacityAbandonFlag = false;
    /**
     * 是否满足神经网络模型舍弃条件
     */
    public Boolean netModelAbandonFlag= false;
    /**
     * 摄入时间 年月日
     */
    public String ingestionDate;
    /**
     * 摄入时间 年月日 时分秒
     */
    public String ingestionTime;
    /**
     * soh估算处理结束时间 年月日
     */
    public String handleEndDate;
    /**
     * soh估算处理结束时间  年月日 时分秒
     */
    public String handleEndTime;

    /**
     * 数据处理日期  年-月-日
     */
    public String processDate;
    /**
     * soh估算规则
     */
    public HashMap<String,ConfigData> configDataMap=new HashMap<>();


    public EstimateSohRecordPhev(){
        super();
    }

    public EstimateSohRecordPhev(BigDecimal BMS_BattSOC,String model_code, Integer HCU_PowertrainSts, BigDecimal longitude, BigDecimal latitude, BigDecimal BMS_SOH_R, String deviceId, String model, String vehicletype , BigDecimal BMS_CellVoltMin, BigDecimal dvMin, BigDecimal BMS_CellMaxVolt, BigDecimal dvMax, BigDecimal Q_Charge, BigDecimal Q_Discharge, BigDecimal cumulativeChrgAhRm, BigDecimal cumulativeDchrgAhRm, BigDecimal totlAh, BigDecimal dQ, BigDecimal ratio1, BigDecimal ratio2, BigDecimal BMS_PackCurr_RM, Long item_time, String license_plate, String cell_battery_type, Integer BMS_ModuleTempaverage, BigDecimal pack_capacity, BigDecimal BMS_CellSOCMax, BigDecimal differenceSocMax, BigDecimal BMS_CellSOCMin, BigDecimal differenceSocMin, Boolean platformValidFlag, Boolean platformValidFlagMax, Boolean platformValidFlagMin, Boolean triggerFlag, Boolean enableFlag, Boolean sleepStillFlag, Boolean onlineStillFlag, Boolean capacityAbandonFlag, Boolean netModelAbandonFlag, String ingestionDate, String ingestionTime, String handleEndDate, String handleEndTime, String processDate) {
        this.BMS_BattSOC = BMS_BattSOC;
        this.model_code = model_code;
        this.HCU_PowertrainSts = HCU_PowertrainSts;
        this.longitude = longitude;
        this.latitude = latitude;
        this.BMS_SOH_R = BMS_SOH_R;
        this.deviceId = deviceId;
        this.model = model;
        this.vehicletype = vehicletype;
        this.BMS_CellVoltMin = BMS_CellVoltMin;
        this.dvMin = dvMin;
        this.BMS_CellMaxVolt = BMS_CellMaxVolt;
        this.dvMax = dvMax;
        this.Q_Charge = Q_Charge;
        this.Q_Discharge = Q_Discharge;
        this.cumulativeChrgAhRm = cumulativeChrgAhRm;
        this.cumulativeDchrgAhRm = cumulativeDchrgAhRm;
        this.totlAh = totlAh;
        this.dQ = dQ;
        this.ratio1 = ratio1;
        this.ratio2 = ratio2;
        this.BMS_PackCurr_RM = BMS_PackCurr_RM;
        this.item_time = item_time;
        this.license_plate = license_plate;
        this.cell_battery_type = cell_battery_type;
        this.BMS_ModuleTempaverage = BMS_ModuleTempaverage;
        this.pack_capacity = pack_capacity;
        this.BMS_CellSOCMax = BMS_CellSOCMax;
        this.differenceSocMax = differenceSocMax;
        this.BMS_CellSOCMin = BMS_CellSOCMin;
        this.differenceSocMin = differenceSocMin;
        this.platformValidFlag = platformValidFlag;
        this.platformValidFlagMax = platformValidFlagMax;
        this.platformValidFlagMin = platformValidFlagMin;
        this.triggerFlag = triggerFlag;
        this.enableFlag = enableFlag;
        this.sleepStillFlag = sleepStillFlag;
        this.onlineStillFlag = onlineStillFlag;
        this.capacityAbandonFlag = capacityAbandonFlag;
        this.netModelAbandonFlag = netModelAbandonFlag;
        this.ingestionDate = ingestionDate;
        this.ingestionTime = ingestionTime;
        this.handleEndDate = handleEndDate;
        this.handleEndTime = handleEndTime;
        this.processDate = processDate;
    }

    /**
     *
     * @param split 分隔符
     * @return
     */
    public String getPropertyInfo(String split){
        String record="";
        Field[] fields = this.getClass().getDeclaredFields();
        try {
            for (int i = 0; i < fields.length; i++) {
                String name = fields[i].getName();
                if(!"configDataMap".equals(name)){
                    Object obj = fields[i].get(this);
                    if(Objects.nonNull(obj)){
                        record+=obj.toString()+split;
                    }else{
                        record+=""+split;
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        if(record.contains(split)){
            record=record.substring(0,record.lastIndexOf(split));
        }
        return record;
    }


}
